import React, { Component } from 'react'
import { NavBar, Button } from 'components'

export default class PayFinish extends Component<any, any> {

    public render(): JSX.Element {
        return (
            <div className="customerServiceResult">
                <NavBar title={<div style={{ fontSize: '0.97rem', color: '#222' }}>提交成功</div>} fixed={true} />
                <div className="customerServiceResult_resultImg">
                    <img src={require('../../assets/submit_success.png')} />
                </div>
                <div className="customerServiceResult_resultText">
                    <div>
                        <p>订单支付成功</p>
                    </div>
                </div>
                <div className="customerServiceResult_operation">
                    <div>
                        <Button
                            className="customerServiceResult_btn"
                            onClick={this.moveToView}
                        >
                            查看订单
                        </Button>
                        <Button
                            className="customerServiceResult_btn"
                            onClick={() => { this.goToUrl(`/`) }}
                        >
                            返回首页
                        </Button>
                    </div>
                </div>
            </div>
        )
    }

    private goToUrl = (url: string = '/') => {
        this.props.history.push(url)
    }

    private moveToView = () => {
        const { params } = this.props.match
        switch (params.type) {
            case '3': {
                this.goToUrl(`/My/myOrder/`)
                return
            }
            default: this.goToUrl(`/My/orderDetail/${params.orderId}`)
        }
    }
}